package com.ihg.hiex.admin.dao.account;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.ihg.hiex.entity.user.Delegate;
import com.ihg.hiex.entity.user.DelegateAttribute;

/**
 * @author ZEAL
 *
 */
@Dao("hibernate")
public interface DelegateDao {
    /**
     * 
     * @param email
     * @return
     */
    @Query("FROM Delegate WHERE disabled = false AND email = :email")
    public Delegate load(@Variable("email") String email);
    
    /**
     * 
     * @param ids
     * @return
     */
    @Query("FROM Delegate WHERE disabled = false AND id IN (:ids)")
    public List<Delegate> list(@Variable("ids") List<Long> ids);
    
    /**
     * 
     * @param delegates
     * @return
     */
    @Query("FROM DelegateAttribute WHERE disabled = false AND delegate in(:delegates)")
    public List<DelegateAttribute> listAttribute(@Variable("delegates") List<Delegate> delegates);
    
    /**
     * 
     * @param name
     * @param value
     * @return
     */
    @Query("SELECT attr.delegate FROM DelegateAttribute attr WHERE attr.name = :name AND attr.value = :value")
    public List<Delegate> list(@Variable("name") String name, @Variable("value") String value);
    
    /**
     * 
     * @param delegate
     * @return
     */
    @Query("FROM DelegateAttribute WHERE disabled = false AND delegate = :delegate")
    public List<DelegateAttribute> listAttribute(@Variable("delegate") Delegate delegate);


}
